#!/usr/bin/env python

import sys,os

def build(bld):
    bld.add_subdirs('pthread nested')

    fastBenchs = [ 'test_reconfig', 'test_reconfig_scanf', 'test_fi_fir', 'test_noc_gamma']

    files = os.listdir('test_code')
    files = filter( lambda x: x.endswith('.c') and os.path.splitext(os.path.basename(x))[0] in fastBenchs, files )

    for f in files:
        obj = None
        for arch in bld.lst_variants:
            if arch == 'default': continue
            if not obj:
                obj = bld.new_task_gen('cc','program')
                obj.env = bld.env_of_name(arch).copy()
                obj.source = f
                obj.env.append_unique('LINKFLAGS', '-lm')
                obj.target = os.path.splitext(f)[0]
#                obj.uselib_local = 'pthread_stub_'+arch
            else:
                obj.clone(arch)

    for arch in bld.lst_variants:
        if arch == 'default': continue

        obj = bld.new_task_gen(features='cc cprogram')
        obj.env = bld.env_of_name(arch).copy()
        obj.source = """
            test_reconfig_multi.c 
        """
        obj.target = 'test_reconfig_multi'
        obj.uselib_local = 'pthread_stub_'+arch 
